//
//  BCShopInfoCell.m
//  BangcaiBuy
//
//  Created by lsy on 16/6/21.
//  Copyright © 2016年 BCB. All rights reserved.
//

#import "BCShopInfoCell.h"

@interface BCShopInfoCell ()
{
    UILabel *nameLabel;
    UILabel *phoneLabel;
    UILabel *addressLabel;
    UIImageView *position;
    UIImageView *arrow;
    UIImageView *line;
}
@end

@implementation BCShopInfoCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView
{
    nameLabel = [[UILabel alloc] init];
    nameLabel.font = [UIFont systemFontOfSize:16];
    phoneLabel = [[UILabel alloc] init];
    phoneLabel.font = [UIFont systemFontOfSize:14];
    addressLabel = [[UILabel alloc] init];
    addressLabel.font = [UIFont systemFontOfSize:16];
    position = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"定位"]];
    line = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"地址-线"]];
    arrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"下一步-灰"]];
    
    [self.contentView addSubview:nameLabel];
    [self.contentView addSubview:phoneLabel];
    [self.contentView addSubview:addressLabel];
    [self.contentView addSubview:arrow];
    [self.contentView addSubview:position];
    [self.contentView addSubview:line];
}

-(void)layoutSubviews
{
    [position mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.width.mas_equalTo(14);
        make.height.mas_equalTo(17);
        make.top.mas_equalTo(20);
        
    }];
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(position.mas_right).with.offset(12);
        make.top.mas_equalTo(20);
        make.width.mas_equalTo(130);
        make.height.mas_equalTo(20);
        
    }];
    
    [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(nameLabel.mas_right);
        make.right.mas_equalTo(-50);
        make.top.and.height.equalTo(nameLabel);
        
    }];
    [addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.height.equalTo(position);
        make.right.equalTo(phoneLabel);
        make.top.mas_equalTo(nameLabel.mas_bottom).with.offset(18);
        
    }];
    
    [arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(10);
        make.centerY.equalTo(self.contentView);
        make.right.mas_equalTo(-10);
        make.height.mas_equalTo(16);
        
    }];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(addressLabel.mas_bottom).with.offset(20);
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(2);
        
        
    }];
    
    nameLabel.text = [NSString stringWithFormat:@"收货人: %@", _name];
    phoneLabel.text = [NSString stringWithFormat:@"%@", _phone];
    addressLabel.text = [NSString stringWithFormat:@"收货地址: %@", _address];
    
}

@end
